<template>
  <div class="layui-layout layui-layout-admin">
    <div class="adminnav1">
      <Pagetop></Pagetop>
    </div>
    <div class="adminnav2">
      <Secondnav urlname="shopmall"></Secondnav>
    </div>

    <!-- 主体内容 -->
    <div class="layui-body kedou-admin" id="LAY_app_body app">
      <div class="layadmin-tabsbody-item layui-show">
        <div class="pagelist">
          <div class="layui-card-body">
            <fieldset class="layui-elem-field layui-field-title">
              <legend>门店管理</legend>
            </fieldset>
          </div>
          <div class="layui-card-body">
            <div class="buttop">
              <button type="button" class="layui-btn  layui-btn-normal" @click="addData">
                添加门店
              </button>
            </div>
            <Tables :fdate="pdate" :result="res" height="430" :totalCount="totalRows" :pageNumber="curindex"
              :fbtn="btn"></Tables>
          </div>

        </div>
      </div>
    </div>
  </div>
</template>
<script>
import Pagetop from "../../common/pagetop.vue";
import Secondnav from "../../common/secondnav.vue";
import Tables from "../../common/tables.vue";
import Search from "../../common/search.vue";
export default {
  name: "shopsetList",
  components: { Pagetop, Secondnav, Tables, Search },
  data () {
    return {
      pdate: [], //表头
      res: "", //内容
      totalRows: "", //总数量
      curindex: 0, //页数
      btn: [], //按钮
      searchArr: [], //搜索
      isShow: false,
      seapram: "",
      shopId: localStorage.getItem("shopId")
    };
  },
  mounted () {
    this.getdate();
    this.getsearch();
  },
  methods: {
    getdate: function () {
      var _this = this;
      var url = "/advert/bapi/v1.9/apply-setting/";
      if (_this.seapram) {
        var dates = {
          size: pageSize,
          pageSize: pageSize,
          pageNumber: 1
        };
        var res = _this.seapram;
        for (var i = 0; i < res.length; i++) {
          dates[res[i].key] = res[i].val;
        }
      } else {
        var dates = {
          size: pageSize,
          page: this.curindex
        };
      }
      // alert(url + "//" + JSON.stringify(dates))
      ajaxRequest(url, "GET", "json", dates, function (ret, err) {
        // alert(url + "//" + JSON.stringify(ret))
        var arr = [];
        arr[0] = [
          { field: "id", title: "ID" },
          { field: "dealerId", title: "商家ID" },
          { field: "applyName", title: "应用名称" },
          { field: "dealerName", title: "商家名称" },
          {
            field: "auditStatus",
            title: "邮箱认证状态",
            templet: function (d) {
              if (d.auditStatus == "UNAUDITEDD") return "待审核";
              else if (d.auditStatus == "AUDIT_PASS") return "审核通过";
              else return "审核不通过";
            }
          },
          {
            field: "auditAt",
            title: "审核时间",
            width: "200",
            templet: function (d) {
              return FormatDate(d.auditAt, 3);
            }
          },
          {
            field: "right",
            title: "操作",
            width: "120",
            fixed: "right",
            templet: function (d) {
              var str =
                '<a class="layui-btn layui-btn-xs layui-btn-normal" lay-event="edit">编辑</a>';
              str =
                str +
                '<a class="layui-btn layui-btn-xs layui-btn-danger" lay-event="set">设置申请</a>';
              return str;
            }
          }
        ];
        _this.pdate = arr;
        _this.res = ret.data.list;
        _this.totalRows = ret.data.totalRows;
        _this.curindex = ret.data.page + 1;
      });
    },
    getsearch: function () {
      var arr = [{ field: "id", title: "商家名ID", type: "input" }];
      this.searchArr = arr;
    },
    page: function (index, obj) {
      //alert(JSON,stringify(obj))
      this.curindex = index;
      this.getdate();
    },
    sousuo: function (pram) {
      //alert(JSON.stringify(pram))
      this.seapram = pram;
      this.res = "";
      this.totalRows = "";
      this.curindex = "";
      this.getdate();
    },
    screens: function () {
      return screen();
    },
    addData: function () {
      layer.open({
        type: 2,
        title: "添加门店",
        content: baseurl + '/shopsetadd',
        area: ["50%", "60%"]
      });
    },
    editInfo: function (data) {
      var _this = this;
      layer.open({
        type: 2
        , title: '编辑门店'
        , content: baseurl + '/shopsetadd'
        , area: ['50%', '60%']
        , success: function (layero, index) {
          var iframeWin = window[layero.find('iframe')[0]['name']];
          iframeWin.getdates(data);
        },
      });
    },
    setInfo: function (data) {
      var _this = this;
      layer.open({
        type: 2
        , title: '申请列表'
        , content: baseurl + '/shopsetem'
        , area: ['40%', '70%']
        , success: function (layero, index) {
          var iframeWin = window[layero.find('iframe')[0]['name']];
          iframeWin.getdates(data);
        },
      });
    },
  },
  updated: function () {
    this.isShow = true;
    layui.use("form", function () {
      var form = layui.form;
      form.render();
    });
  }
};
</script>
<style scoped>
/**/
</style>
